package enemies.dao.impl;
 
import java.util.List;

import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Repository;

import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.client.MongoCollection;

import enemies.dao.IMongoCommonDao;
 
@Repository
public class MongoCommonDaoImpl implements IMongoCommonDao {
    @Autowired
    private MongoTemplate mongoTemplate;
 
    private DBCollection getCollection(String collectionName)
    {
        return mongoTemplate.getCollection(collectionName);
    }
 
    @Override
    public void saveDataToMongoDB(String collectionName, Document document) {
    	DBCollection collection = getCollection(collectionName);
        collection.insert((List<? extends DBObject>) new Document().append("test", "测试保存数据"));
    }
}
